    //
//  YAYIPersoninfoHeadCell.m
//  yayi
//
//  Created by Veer on 16/3/18.
//  Copyright © 2016年 hxp. All rights reserved.
//

#import "YAYIAppointDetailHeadCell.h"
//#import "YAYISettingItem.h"


@implementation YAYIAppointDetailHeadItem
@end


@interface YAYIAppointDetailHeadCell()

@property (nonatomic, weak) UIImageView *iconVw;
@property (nonatomic, weak) UILabel *nameLbl;
@property (nonatomic, weak) UILabel *mobileLbl;

@end

@implementation YAYIAppointDetailHeadCell

- (void)setItem:(YAYIAppointDetailHeadItem *)item
{
    _item = item;
    
    NSString *iconUrlStr = [NSString stringWithFormat:@"%@%@", API, item.avatar];
    [self.iconVw sd_setImageWithURL:[NSURL URLWithString:iconUrlStr] placeholderImage:[UIImage imageNamed:@"doctor"] options:SDWebImageRefreshCached];

    self.nameLbl.text = item.patientName;
    self.mobileLbl.text = item.mobile;
}

+ (instancetype)cellWith:(UITableView *)tableview
{
    static NSString *cellID = @"mecell";
    
    YAYIAppointDetailHeadCell *cell = [tableview dequeueReusableCellWithIdentifier:cellID];
    //YAYIPersoninfoCell *cell = [super cellWith:tablevie];
    
    if (nil == cell) {
        cell = [[YAYIAppointDetailHeadCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
        // 添加icon
        [self setupSubview];
    }
    return self;
}


- (void)setupSubview
{
    //
    UIImageView *iconVw = [[UIImageView alloc] init];
    iconVw.image = [UIImage imageNamed:@"doctor"];
    iconVw.contentMode = UIViewContentModeScaleAspectFill;
    iconVw.layer.masksToBounds = YES;
    [self.contentView addSubview:iconVw];
    self.iconVw = iconVw;
    
    //
    UILabel *nameLbl = [[UILabel alloc] init];
    nameLbl.font = [UIFont systemFontOfSize:17];
    //nameLbl.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:nameLbl];
    self.nameLbl = nameLbl;
    
    //
    UILabel *mobileLbl = [[UILabel alloc] init];
    mobileLbl.font = [UIFont systemFontOfSize:15];
    mobileLbl.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:mobileLbl];
    self.mobileLbl = mobileLbl;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat margin = 10;
    // 设置frame
    [self.iconVw mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(margin);
        make.bottom.mas_equalTo(-margin);
        make.leading.mas_equalTo(margin * 2);
        make.width.mas_equalTo(self.iconVw.mas_height);
        
        
    }];
    self.iconVw.layer.cornerRadius = 30;
    
    
    //
    [self.nameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(margin);
        make.left.mas_equalTo(self.iconVw.mas_right).mas_offset(margin);
        make.right.mas_equalTo(self.mas_right);
        make.height.mas_equalTo(self.iconVw.mas_height).multipliedBy(0.5);
    }];
    ////
    [self.mobileLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-margin);
        make.left.mas_equalTo(self.iconVw.mas_right).mas_offset(margin);
        make.right.mas_equalTo(self.mas_right);
        make.height.mas_equalTo(self.iconVw.mas_height).multipliedBy(0.5);
    }];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


@end
